Golang GUI编程:walk.WebView实现web app 您所在的位置:网站首页 go gui编程vue Golang GUI编程:walk.WebView实现web app

Golang GUI编程:walk.WebView实现web app

2023-11-20 19:30| 来源: 网络整理| 查看: 265

本程序采用github.com/lxn/walk的walk.WebView实现一个GUI程序,启动一个http server,GUI访问本地http server。

支持写日志、响应键盘事件等。

完整代码:

main.go

//先安装mingw64 package main import ( "os" "strings" "time" "github.com/go-vgo/robotgo" "github.com/lxn/walk" . "github.com/lxn/walk/declarative" hook "github.com/robotn/gohook" ) //写日志 func WriteLog(str_content string) { fd, _ := os.OpenFile("./log.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) fd_time := time.Now().Format("2006-01-02 15:04:05") fd_content := strings.Join([]string{fd_time, ": ", str_content, "\n"}, "") buf := []byte(fd_content) fd.Write(buf) fd.Close() } //响应键盘事件 func KeyEvent() { for 1 == 1 { robotgo.EventHook(hook.KeyDown, []string{"esc"}, func(e hook.Event) { if isFullScreen { NormalScreen() }else{ FullScreen() } robotgo.EventEnd() }) s := robotgo.EventStart()


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有